package com.study.webapp.leetcode;

public class Leet_45 {


    public static void main(String[] args) {
        int[] a = {3,2,1};
        System.out.println(jump1(a));
    }


    public static int jump1(int[] nums) {
        if (nums.length <=1) {
            return 0;
        }
        int len = nums.length;
        int j = 0;
        int end = 0;
        int s = 0;
        for(int i = 0;i<len-1;i++) {
           j = Math.max(j,i+nums[i]);
           if (i == end) {
               end = j;
               s++;
           }
        }
        return s;
    }
}
